package com.tanhua.app.controller;

import com.tanhua.app.service.SettingsService;
import com.tanhua.domain.db.Settings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class SettingsController {

    @Autowired
    private SettingsService settingsService;

    @GetMapping("/users/settings")
    public ResponseEntity findSettingsVo(){
        return settingsService.findSettingsVo();
    }




    //设置陌生人问题
    @PostMapping(value = "/users/questions", name = "设置陌生人问题")
    public ResponseEntity saveQuestion(@RequestBody Map param) {
        String content = (String) param.get("content");
        return settingsService.saveQuestion(content);
    }
    //设置通知
    @PostMapping(value = "/users/notifications/setting",name = "设置通知")
    public ResponseEntity saveSettings(@RequestBody Settings settings){

        return settingsService.saveSettings(settings);
    }
    @GetMapping(value = "/users/blacklist", name = "黑名单分页查询")
    public ResponseEntity findBlackListPage(@RequestParam(name = "page" ,defaultValue = "1")Integer page,
                                            @RequestParam(name = "pagesize",defaultValue = "10")Integer pagesize){
        System.out.println(page);
        System.out.println(pagesize);
        return settingsService.findBlackListPage(page,pagesize);

    }
    //删除黑名单
    @DeleteMapping("/users/blacklist/{blackUserId}")
    public ResponseEntity deleteBlack(@PathVariable Long blackUserId){
        return settingsService.deleteBlack(blackUserId);
    }
}
